var baseinfoids=utils.getParameter("ids");
$(function () {
    $("#jqGrid").jqGrid({
        url: '../recruitdamand/list',
        datatype: "json",
        colModel: [			
			{ label: 'id', name: 'id', index: 'id', width: 50, key: true ,hidden: true},
			{ label: '用工单位', name: 'settlementid', index: 'settlementid',hidden: true },
            { label: '用工单位名称', name: 'settlementname', index: 'settlementname' },
            { label: '需求编号', name: 'damandid', index: 'damandid',hidden: true },
			{ label: '岗位编号', name: 'jobid', index: 'jobid',hidden: true },
			{ label: '岗位名称', name: 'jobname', index: 'jobname' },
            { label: '需求人数', name: 'empnum', index: 'empnum' },
            { label: '完成招聘日期', name: 'finishdate', index: 'finishdate' },
			{ label: '性别', name: 'sex', index: 'sex' }, 			
			{ label: '最大年龄', name: 'topage', index: 'topage' }, 			
			{ label: '最小年龄', name: 'lowage', index: 'lowage' }, 			
			{ label: '学历', name: 'education', index: 'education' }, 			
			{ label: '婚否', name: 'married', index: 'married' }, 			
			{ label: '证书名称', name: 'certificatename', index: 'certificatename' }			
        ],
		viewrecords: true,
        height: 300,
        rowNum: 30,
		rowList : [10,30,50],
        rownumbers: true,
        autowidth:true,
        //字段太多自动加载横轴滚动条
        shrinkToFit:false,
        autoScroll: false,
        multiselect:false,//只允许单选
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
            //doResize();
            //显示grid底部滚动条
            //$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "scroll" });
        }
    });
});
var vm = new Vue({
    el: '#rrapp',
    data: {
        q: {
            settlementname: null
        },
        showList: true,
        showTable: true,
        title: null,
        recruitdamand: {},
        list: {}
    },
    methods: {
        add: function () {
            var ids = getSelectedRows();
            if(ids == null){
                return ;
            }
            var demandid=$("#jqGrid").jqGrid("getGridParam","selrow");//获取一行记录id
            var params = {
                demandid:demandid,
                baseinfoids:baseinfoids
            }
            $.ajax({
                type: "POST",
                url: "../empbaseinfo/insertinterview",
                contentType: "application/json",
                data: JSON.stringify(params),
                dataType:"json",
                async:false,
                cache:false,
                success: function(r){
                    if(r.code === 0){
                        alert('操作成功', function(index){
                            utils.closeCurrentPage();

                        });
                    }else{
                        alert(r.msg);
                    }
                }
            });

        },
        close:function () {
            utils.closeCurrentPage();
        },
        reload: function (event) {
            vm.showList = true;

            var page = $("#jqGrid").jqGrid('getGridParam','page');
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{'settlementname': vm.q.settlementname},
                page:page
            }).trigger("reloadGrid");
        },
        query:function () {
            vm.reload();
        }

    }

})
